<?php
	namespace Admin\Controller;

	use Think\Controller;

	class UserController extends CommonController{
		public function index(){
			$model = D('User');
			$userlist=$model->getAll();//在AdminUserModel.class.php中

			$this->assign('userlist',$userlist);

			$this->display();
		}
		public function Ustatus(){
			$id=$_GET['id'];

			$model= M ('User');
			//获取表但信息
			$list=$model->field('status')->where('id='.$id)->select();
			// var_dump($list);
			if ($list[0]['status']==1) 
			{
				$res=$model->where('id='.$id)->save(['status'=>0]);
				$this->redirect('User/index');
			}else{
				$res=$model->where('id='.$id)->save(['status'=>1]);
				$this->redirect('User/index');
			}
			// $model->UpStatus($id);
		}

		//删除用户
		public function delete(){

			$id=$_GET['id'];
			$model= D ('User');

			$res=$model->del($id);
			$this->redirect('User/index');
		}

		//充值密码
		public function reset(){

			$id=$_GET['id'];
			$model= D ('User');
			$res = $model ->resets($id);
			if ($res) {
				$this->success('重置成功,初始密码123456',U('User/index'));
			}else{
				$this->success('重置失败',U('User/index'));
			}
		
		}

		
	}